<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML>
<html lang="en">
<head>
<base href="<%=basePath%>">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/bootstrap.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/main.css">
<script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/js/main.js"></script>
<title>商城管理系统</title>
<style>
.main_div {
	min-width: 1000px
}

.center {
	width: 200px;
	height: 100px;
	background-color: #ccc;
	position: absolute;
	left: 50%;
	top: 50%;
	margin-left: -100px;
	margin-top: -50px;
	z-index: 10;
	text-align: center;
	line-height: 50px;
	border-radius: 6px;
}
</style>
</head>
<body>
	<%@ include file="header.jsp"%>
	<%@ include file="left.jsp"%>
	<div id="index"
		style="position: absolute;left: 180px;top: 80px;bottom: 0;right: 0;">
		<section id="main">
			<div class="scrollbar1-1" id="style1-1">
				<div class="main_div">
					<div class="main_title">
						<span>banner管理</span>
					</div>
						<div class="col-xs-4"  style="margin-top:30px ;">
							<button id="setButton" class="col-xs-4 btn btn-primary"
								type="button" onclick='detailinfos()'>添加banner</button>
						</div>
				</div>
				
				<div class="force-overflow1-1">
					<table id="showtable"
						class="table table-condensed table-bordered table-hover"
						style="text-align: center">
						<tr style="background-color: #f8f8f8">
							<th style="text-align: center;color: #000">序号</th>
							<th style="text-align: center;color: #000">banner图片</th>
							<th style="text-align: center;color: #000">修改</th>
							<th style="text-align: center;color: #000">删除</th>
						</tr>
					</table>
					<div class="pageChange" style="margin-bottom:30px">
						<span onclick="prePage()">&nbsp;&nbsp;上一页&nbsp;&nbsp;</span> <span
							onclick="nextPage()">&nbsp;&nbsp;下一页&nbsp;&nbsp;</span> <em>
							&nbsp; 第&nbsp;<span id="pageNum">1</span>&nbsp;页&nbsp;&nbsp;
						</em> <em>/&nbsp;&nbsp;共&nbsp;<span id="totalpage"></span>&nbsp;页
						</em> <em>&nbsp;&nbsp;&nbsp;跳到第<input id="searchInput"
							style="width:46px" maxlength="4" type="text">页
						</em>
						<button class="btn btn-primary" onclick="searchPage()">搜索</button>
					</div>
				</div>
			</div>
		</section>
	</div>
	<script>
		$(function() {
			selectinfo();
		})	
		function selectinfo() {
			var pageNum = $("#pageNum").html();
			var pageCount = $("#pageCount").val();
			var productNames = $("#productNames").val();
			if (!productNames) {
				productNames = null
			}
			$.post(urls + "utilAction/selectIndexBanner",
				{
				},
				function(data) {
					console.log(data)
					if (data) {
					//	var totalpage = data.totalpage;
						var orderlist = data;
						var table = $("#showtable");
						$("tr").remove(".addtr");
						for (var i = 0; i < orderlist.length; i++) {
							var hots = "";
							if (orderlist[i].putaway == 0) {
								hots = "<button class='btn btn-success' onclick='isPutaway(\"" + orderlist[i].id + "\",1)'>点击上架</button>"
							} else if (orderlist[i].putaway == 1) {
								hots = "<button class='btn btn-primary' onclick='isPutaway(\"" + orderlist[i].id + "\",0)'>点击下架</button>"
							}
							var append = "<tr id='" + orderlist[i].id + "'  class='addtr'><td style='line-height:180px'>" + (i + 1) + "</td>" +
								"<td ><img style='width:375x;height:180px' src='/SLYSTYG/main/" + orderlist[i].bannerImg + "' alt='加载中'/> </td>" +
								"<td style='line-height:180px'><input onclick='deletBurst(\"" + orderlist[i].id + "\")' type='button' class='btn btn-primary' value='删除' /> </td>" +
								"<td style='line-height:180px'><input onclick='detailinfo(\"" + orderlist[i].id + "\")' type='button' class='btn btn-primary' value='修改' /></td></tr>";
							table.append(append);
						}
					//	$("#totalpage").html(totalpage);
					}
				}
				, "json"
			)
		}
		function deletBurst(e) { //删除爆款
			if (confirm("是否删除banner？")) {
				$.post(urls + "utilAction/deleteIndexBanner",
					{
						id : e
					},
					function(res) {
						if (res) {
							$("#" + e).css("display", "none")
						} else {
							alert("删除Banner失败")
						}
					})
			}
		}
		function detailinfos() { //添加		
			location.href = "${pageContext.request.contextPath}/YMGback/direct/addBanner.jsp"
		}
		function detailinfo(e) { //点击修改
			location.href = "${pageContext.request.contextPath}/YMGback/direct/changeBanner.jsp?id=" + e
		}
	</script>
</body>
</html>